# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gdbm

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.10
pkgrel=1
pkgdesc="GNU database library (mingw-w64)"
arch=('any')
url="http://www.gnu.org/software/gdbm/gdbm.html"
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-gettext" "${MINGW_PACKAGE_PREFIX}-libiconv" )
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs')
source=(ftp://ftp.gnu.org/gnu/gdbm/${_realname}-${pkgver}.tar.gz{,.sig}
    'gdbm-1.10-zeroheaders.patch'
    'gdbm-win32-support.patch')
md5sums=('88770493c2559dc80b561293e39d3570'
         'SKIP'
         'ac255b10452005237836cd2d3a470733'
         'ce7d37d8d7cfc895ccd04a59adabbbbe')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/gdbm-1.10-zeroheaders.patch
  patch -p1 -i ${srcdir}/gdbm-win32-support.patch

  autoreconf --install --force
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  
  ${srcdir}/${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
  --host=${MINGW_CHOST} \
  --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
  --enable-static \
  --enable-shared \
  --enable-libgdbm-compat

  make
}

check() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make check
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} install
}
